package com.example.big_orange2.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.big_orange2.entity.lockorder;
import com.example.big_orange2.entity.orderdata;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

@Mapper
public interface lockorderMapper extends BaseMapper<lockorder> {

    @Select("select userid,sum(fee) 'fee' from lockorders group by userid")
    List<lockorder> getmongeydata();

    @Select("select lo.lockclassname,sum(fee) 'fee' from lockorders ll,sharelocks sh,lockrules lo " +
            "  where ll.sharelockid=sh.sharelockid and sh.lockclassid=lo.lockclassid group by lo.lockclassname")
    List<orderdata> getorderdata();

    //注解方式调用过程
    @Select("{call endorder(#{map.lid,jdbcType=INTEGER,mode=IN},"
            + "#{map.sid,jdbcType=INTEGER,mode=IN},"
            + "#{map.money,jdbcType=FLOAT,mode=IN},"
            + "#{map.uid,jdbcType=INTEGER,mode=IN})}")
    @Options(statementType = StatementType.CALLABLE)
    void endpay(@Param("map") Map<String, Object> map);

    //xml配置调用存储过程
//    public String endorder(@Param("arg0") int lid, @Param("arg1") int sid,@Param("arg2") float money, @Param("arg3") int uid);
}